﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using PopupControl;

namespace SharpDiary.Core.Controls
{
    public partial class DiaryTagButton : UserControl
    {
        private TagSelector _tagSelector = new TagSelector();

        /// <summary>
        /// 获取或设置标签。
        /// </summary>
        public string Tags
        {
            get { return _tagSelector.Tags; }
            set
            {
                _tagSelector.Tags = value;
                lblText.Text = value;
            }
        }

        public DiaryTagButton()
        {
            InitializeComponent();

            DoubleBuffered = true;
            ResizeRedraw = true;

            BackColor = Color.Transparent;
        }

        private void lblText_Click(object sender, EventArgs e)
        {
            Popup popup = new Popup(_tagSelector);
            popup.Closed += new ToolStripDropDownClosedEventHandler(popup_Closed);
            popup.Show(lblText, new Point(0, 0), ToolStripDropDownDirection.AboveRight);
        }

        void popup_Closed(object sender, ToolStripDropDownClosedEventArgs e)
        {
            lblText.Text = _tagSelector.Tags;
        }

    }
}
